SetAxisGearInPos
從同步點開始命令從軸和主軸位置之間的齒輪比率。
注意:使用 SetGearInPos() 前主軸必須在恆定速度的移動狀態。
運作方式:
首先,從軸以 MoveAxisContinuousAbsolute 移動以正確的時間及速度到達 SlaveSyncPosition,Velocity, Acceleration 與 Deceleration 輸入即為此 MoveAxisContinuousAbsolute 移動所設,移動中的 StartSync 輸出為 TRUE,一旦此運動完成,InSync 輸出即為 TRUE。
GearInPos 設定檔:
- 若 MasterStartDistance 非零,主軸位置一到達 MasterSyncPosition +- MasterStartDistance 時從軸即開始移動,Velocity 被視為可能無法達到的最大速度,因此除非速度太低,否則基本上將其省略,接著因為無相容的設定檔將觸發錯誤。
- 若 MasterStartDistance 為零而 Velocity 非零,將根據提供的最大速度計算可能的最短曲線。
- 若 MasterStartDistance 與 Velocity 皆為零,KINGSTAR 將生成可能的最順曲線。
語法
KsCommandStatus SetAxisGearInPos(
int Master,
int Slave,
BOOL Permanent,
double Ratio,
McSource MasterValueSource,
double MasterSyncPosition,
double SlaveSyncPosition,
McSyncMode SyncMode,
double MasterStartDistance,
double Velocity,
double Acceleration,
double Deceleration,
double Jerk,
McBufferMode BufferMode
);
參數
Master [in]:主軸索引。索引以零為起點;別名將影響此參數。
Slave [in]:從軸索引。索引以零為起點;別名將影響此參數。從軸之最大數量為 32 軸。
Permanent [in]:決定馬達停用後是否保留齒輪狀態。
TRUE:馬達停用但保留齒輪狀態,例如當主軸啟用時從軸也會跟著啟用,而當主軸發生錯誤從軸也會發生錯誤。
FALSE:馬達停用後不會保留齒輪狀態。
Ratio [in]:齒輪比例。例如若比例為 3:2,從屬裝置移動三個單位而主裝置移動兩個單位。
MasterValueSource [in]:定義同步的來源。請見 McSource 類型。
- mcSetValue – 同步主軸設定值,建議使用此設定。
- mcActualValue-同步主軸實際值,此設定可能不穩定。
- mcSecondEncoderValue – 軸的第二編碼器實際值。
注意:尚未支援 mcSecondEncoderValue。
MasterSyncPosition [in]:從軸與主軸同步時主軸的位置。
SlaveSyncPosition [in]:從軸與主軸同步時從軸的位置。
SyncMode [in]:決定同步的方式。請見 McSyncMode 類型。
MasterStartDistance [in]:主軸移動至與從軸同步的距離(當從軸開始進入同步時)。
Velocity [in]:同步階段的最大速度。
Acceleration [in]:同步階段的最大加速度。
Deceleration [in]:同步階段的最大減速度。
Jerk [in]:同步階段的最大加加速度。
BufferMode [in]:定義如何融合兩功能的速度,請見 McBufferMode 類型。
回傳值
返回 KsCommandStatus 結構。
備註
- 若使用 MasterStartDistance,則任何先前的運動都會繼續,直到主軸以正確的方向穿過 MasterSyncPosition 或 MasterStartDistance(根據 MasterStartDistance 的指示);若在同步發生之前對從軸執行停止命令,其將取消同步且函式將發送 CommandAborted。
- 若未指定 MasterStartDistance,則系統可根據其他相關輸入計算同步設定點。
- 在 SyncMode 中,
mcCatchUp
與mcSlowDown
間的不同為同步需要的能源,比起mcCatchUp
,mcSlowDown
需要較低的能源。 - 欲分離從軸,請使用 ReleaseAxis。
- 當模數軸啟用時,只有主軸可配置為模數軸,且 MasterSyncPosition 將被轉換為模數值,而 MasterStartDistance 不會被轉換。例如,若模數值為 360,當主軸的目前位置為 0,速度設定為 180/s,且 MasterSyncPosition 設定為 -20,則主軸將使用 340 作為同步位置。
範例
KsCommandStatus AssignGearSlave(INT Master, INT Slave, DOUBLE MasterPosition, DOUBLE SlavePosition) {
KsCommandStatus gear = WaitForCommand(10, FALSE, SetAxisGearInPos(Master, Slave,
False, //Parameter.Permanent
1, //Gear ratio
mcSetValue, /*Master Value Source. Value of the master position used.
Cam be the target position (commanded value and set value are identical)
or the actual position.*/
MasterPosition, //The master's position where the slave is in sync with the master.
SlavePosition, //The slave's position where the slave is in sync with the master.
mcCatchUp, /*Defines the way to synchronize
(such as "mcShortest," "mcCatchUp," "mcSlowDown"). Vendor-specific.*/
0, //This will be calculated automatically if not provided.
3600,
36000,
36000,
3600000,
mcAborting)
);
return gear;
}
使用需求
RT | Win32 | |
---|---|---|
最低支援版本 | 4.0 | 4.0 |
標頭檔 | ksmotion.h | ksmotion.h |
程式庫 | KsApi_Rtss.lib | KsApi.lib |
參見